package com.smart.lib.service;

import com.smart.lib.entity.BookCategoryInfo;
import com.smart.lib.mapper.BookCategoryMapper;
import com.smart.lib.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 图书分类管理实现类
 * */
@Service
public class BookCategoryService {
    @Autowired
    BookCategoryMapper bookCategoryMapper;

    /**
     * 获取所有图书分类信息
     * */
    public Response getAllBookCategory(){
        return new Response(200,"获取所有图书分类信息成功",bookCategoryMapper.getAllBookCategory());
    }

    /**
     * 添加图书分类
     * */
    public Response addBookCategory(BookCategoryInfo bookCategoryInfo){
        Integer counts = bookCategoryMapper.addBookCategory(bookCategoryInfo);
        if(counts>0){
            return new Response(200,"添加成功",null);
        }else{
            return new Response(401,"添加失败",null);
        }
    }

    /**
     * 编辑图书分类
     * */
    public Response editBookCategory(BookCategoryInfo bookCategoryInfo){
        Integer counts = bookCategoryMapper.editBookCategory(bookCategoryInfo);
        if(counts>0){
            return new Response(200,"编辑成功",null);
        }else{
            return new Response(401,"编辑失败",null);
        }
    }
}
